package com.zhongyu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhongyu.mapper.CaiGouMapper;
import com.zhongyu.pojo.Order;
import com.zhongyu.pojo.Provider;
import com.zhongyu.pojo.User;
import com.zhongyu.service.CaiGouService;
import com.zhongyu.vo.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service("caiGouService")
public class CaiGouServiceImpl extends ServiceImpl<CaiGouMapper, Order> implements CaiGouService {
   @Resource
    private CaiGouMapper caiGouMapper;
    @Override
    public PageResult searchAll(Integer pageNo, Integer pageSize) {
        LambdaQueryWrapper<Order> wrapper= Wrappers.<Order>lambdaQuery();
        Page page=new Page(pageNo,pageSize);
        List<Order> list=caiGouMapper.findAll(page,wrapper);
//       System.out.println("==2>"+list.size());
        /* return PageResult.getInstanceByPage(page);*/
        return new PageResult(list,page.getTotal());
    }

    @Override
    public List<Order> searchAll(Integer id) {
        return caiGouMapper.searchAll(id);
    }
    @Override
    public void add(Order order) {
        caiGouMapper.insert(order);
    }
}
